using System;
using FluentNHibernate.AutoMap;
using Webshop20.Domain.Common;
using Webshop20.Domain.Shared.Payment.Core;
using Webshop20.Infrastructure.Persistence.NH.AutoMappings.Conventions.Common;
using Webshop20.Infrastructure.Persistence.NH.AutoMappings.Overrides;

namespace Webshop20.Infrastructure.Persistence.NH.AutoMappings
{
    public class ForPayment
    {
        public static AutoPersistenceModel GetPersistenceModel()
        {
            return
                AutoPersistenceModel.MapEntitiesFromAssemblyOf<CreditCard>()
                                    .Where(x => x.Namespace == "Webshop20.Domain.Shared.Payment.Core")
                                    .UseOverridesFromAssemblyOf<IPaymentOverride>()
                                    .ConventionDiscovery.AddFromAssemblyOf<IdConvention>()
                                    .WithSetup(
                                convention =>
                                {
                                    convention.IsBaseType = bt => bt == typeof(PaymentBase);

                                }
                                    );
        }
    }
}